<?php

namespace common\models;

use common\components\TimestampTrait;
use Yii;

/**
 * This is the model class for table "{{%product}}".
 *
 * @property int $id
 * @property string $goods_sn 产品识别码
 * @property string $price 红包金额
 * @property string $code 3位码前缀
 * @property string $security_sn 防伪码
 * @property string $product_name 产品名称
 * @property int $created_at 创建时间
 * @property int $updated_at 修改时间
 */
class Product extends \yii\db\ActiveRecord
{
    use TimestampTrait;
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%product}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['goods_sn', 'product_name', 'code'], 'required'],
            ['security_sn', 'default', 'value' => ''],
            [['price'], 'number'],
            [['created_at', 'updated_at'], 'integer'],
            [['goods_sn'], 'string', 'max' => 13],
            [['code', 'product_name'], 'string', 'max' => 255],
            [['security_sn'], 'string', 'max' => 8],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'goods_sn' => '产品识别码',
            'price' => '红包金额',
            'code' => '身份码前缀',
            'security_sn' => 'Security Sn',
            'product_name' => '产品名称',
            'created_at' => '创建时间',
            'updated_at' => 'Updated At',
        ];
    }
}
